---@class UIFriendAddMessagePanel : UIComponentBase
local UIFriendAddMessagePanel = Class("",UIComponentBase)
local t = UIFriendAddMessagePanel
local friendId = 0
function t:ctor(obj)
    self.fguiObj = obj
    self:OnCreate()
end

function t:OnCreate()
    self.inputMsg = self:GetChild("textMessage")
    self.btnSend = self:GetChild("confirm")
    self.btnClose = self:GetChild("btnClose")

    self:RegisterOnClick(self.btnSend,self.ClickSend)
    self:RegisterOnClick(self.btnClose,self.ClickClose)
end

function t:OnEnable()

end
function t:OnDisable()
end
function t:OnDestroy()
    self.fguiObj = nil
    self.parent = nil
end
function t:Refresh(id)
    friendId = id
end
function t:ClickSend()
    if self.inputMsg.text ~= "" and logicMgr.ChatManager.HasFilterBlockWord(self.inputMsg.text) then
        UISysTips.AddMsg(getLanguage("UIFriend_ApplyMsgBlock"))
        return
    end
    if logicMgr.FriendManager.IsMaxFriend() then
        UISysTips.AddMsg(getLanguage("ErrorCode_140001"))
        return
    end

    if logicMgr.FriendManager.IsInBlack(friendId) then
        UISysTips.AddMsg("该玩家为黑名单玩家，请先移除黑名单")
        return
    end
    friendHandler.sendAddFriend(friendId,self.inputMsg.text);
    self:ClickClose()
end
function t:ClickClose()
    FireEvent(Config.EventType.FriendShowAddMessage,false)
end
return t